<ul id="accountTree" class="ztree"></ul>
<script type="text/javascript">
var setting = {
		async: {
			enable: true,
			url:"../agent/o_account_tree.jspx",
			autoParam:["root"],
			dataFilter: filter
		},
		callback: {
			onClick: onClick
		}
};

$().ready(function(){
	var accountTree = $.fn.zTree.init($("#accountTree"), setting);
	
})
function onClick( event, treeId, treeNode, clickFlag ){
	if(  treeNode.root ){
		var name = treeNode.name;
		var index = name.indexOf('[');
		if( index != -1 ){
			name = name.substring(0,index);
		}
		$('#recommentAccount').val( name );
	}
}
function filter(treeId, parentNode, childNodes) {
	if (!childNodes) return null;
	for (var i=0, l=childNodes.length; i<l; i++) {
		childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
	}
	return childNodes;
}

</script>